package belleza.relativa

import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils

class InterceptorController {

    def beforeInterceptor = [action: this.&auth, except: 'login']

    def transient springSecurityService

    def auth() {
        def config = SpringSecurityUtils.securityConfig

        if (!springSecurityService.isLoggedIn() && !getSession().getAttribute("esInvitado")) {
            String view = 'auth'
            String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"
            redirect(controller: "login", view: view, model: [postUrl: postUrl,
                    rememberMeParameter: config.rememberMe.parameter])
            return false
        }

    }
}
